home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / DirtWall.as < prev    next >
Text File  |  2013-04-24  |  2KB  |  85 lines

  1. class DirtWall extends State
  2. {
  3.    static var sLINKAGE_NAME = "mcDirtWall";
  4.    var sSTATE_IDLE = "Idle";
  5.    var sSTATE_FALL = "Fall";
  6.    static var nMIN_WAIT_TIME = 200;
  7.    static var nMAX_WAIT_TIME = 500;
  8.    static var nCOUNTER = 0;
  9.    function DirtWall(_nX, _nY)
  10.    {
  11.       super(CTRLGame.getRef().mcRef.attachMovie(DirtWall.sLINKAGE_NAME,DirtWall.sLINKAGE_NAME + DirtWall.nCOUNTER,CTRLGame.getRef().calculateDepth(_nY,CTRLGame.nDIRT_WALL_ADD + DirtWall.nCOUNTER)));
  12.       DirtWall.nCOUNTER = DirtWall.nCOUNTER + 1;
  13.       this.mcRef._x = _nX;
  14.       this.mcRef._y = _nY;
  15.       this.nWaitTime = Math.round(Math.random() * (DirtWall.nMAX_WAIT_TIME - DirtWall.nMIN_WAIT_TIME)) + DirtWall.nMIN_WAIT_TIME;
  16.       if(this.nWaitTime == 0)
  17.       {
  18.          this.setState(this.sSTATE_FALL);
  19.       }
  20.       else
  21.       {
  22.          this.setState(this.sSTATE_IDLE);
  23.       }
  24.       if(Controller.getRef().isPaused())
  25.       {
  26.          this.doPause();
  27.       }
  28.    }
  29.    function cleanUp()
  30.    {
  31.       super.cleanUp();
  32.       this.mcRef.swapDepths(7777);
  33.       this.mcRef.removeMovieClip();
  34.    }
  35.    function doPause()
  36.    {
  37.       super.doPause();
  38.       for(var i in this.mcRef.mcState)
  39.       {
  40.          this.mcRef.mcState[i].stop();
  41.       }
  42.    }
  43.    function doUnPause()
  44.    {
  45.       if(!CTRLGame.getRef().Screen.isInMiniGame())
  46.       {
  47.          super.doUnPause();
  48.          for(var i in this.mcRef.mcState)
  49.          {
  50.             this.mcRef.mcState[i].play();
  51.          }
  52.       }
  53.    }
  54.    function resumeAnim()
  55.    {
  56.       super.doUnPause();
  57.       for(var i in this.mcRef.mcState)
  58.       {
  59.          this.mcRef.mcState[i].play();
  60.       }
  61.    }
  62.    function Idle()
  63.    {
  64.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  65.       {
  66.          this.nWaitTime = this.nWaitTime - 1;
  67.          if(this.nWaitTime <= 0)
  68.          {
  69.             this.setState(this.sSTATE_FALL);
  70.          }
  71.       }
  72.    }
  73.    function Fall()
  74.    {
  75.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  76.       {
  77.          if(this.stateFinished())
  78.          {
  79.             this.setState(this.sSTATE_IDLE);
  80.             this.nWaitTime = Math.round(Math.random() * (DirtWall.nMAX_WAIT_TIME - DirtWall.nMIN_WAIT_TIME)) + DirtWall.nMIN_WAIT_TIME;
  81.          }
  82.       }
  83.    }
  84. }
  85.